class Solution
{
public:
    int maxProduct(vector<string> &words)
    {
        int n = words.size();
        vector<int> mask(n, 0);
        int result = 0;
        for (int i = 0; i < n; ++i)
        {
            for (char c : words[i])
            {
                mask[i] |= 1 << (c - 'a');
            }
            for (int j = 0; j < i; ++j)
            {
                if (mask[i] & mask[j])
                {
                    continue;
                }
                result = max(result, static_cast<int>(words[i].size() * words[j].size()));
            }
        }
        return result;
    }
};